package com.jun.PageHelper;

import java.util.List;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jun.flower.bean.TbFlowers;
import com.jun.flower.dao.TbFlowersMapper;

public class testPageHelper {
	@Test
	public void testPageHelper(){
		//设置分页信息
		PageHelper.startPage(1, 5);
		//初始化spring容器
		ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:applicationContext-dao.xml");
		//从容器中获得mapper的代理对象
		TbFlowersMapper flowerMapper = applicationContext.getBean(TbFlowersMapper.class);
		//执行查询
		List<TbFlowers> list = flowerMapper.selectByExample(null);
		//取分页结果
		PageInfo<TbFlowers> pageInfo = new PageInfo<>(list);
		System.out.println("总记录数"+pageInfo.getTotal());
		System.out.println("总页数"+pageInfo.getPages());
		System.out.println("list中的数据行数"+list.size());
	}
}
